<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>图书借阅系统首页</title>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="/css/index.css">
</head>
<body>
<div class="header">
    <div class="logo">
        <img src="/images/Logo.png">
    </div>
    <div class="title">
        欢迎使用图书借阅系统
    </div>
    <div class="nav">
        <ul>
            @if($user->is_admin == 1)
                <li><a href="/admin">管理员入口</a></li>
            @endif
            <li><a href="/person">个人中心</a></li>
                <li>欢迎您，{{$user->username}}</li>
        </ul>
    </div>
</div>
<div class="content">
    <form action="/book" method="GET">
        <div class="soso">
            <div class="select">
                <select name="query">
                    <option value="name">按书名查询</option>
                    <option value="bookid">按书号查询</option>
                    <option value="author">按作者查询</option>
                    <option value="publisher">按出版社查询</option>
                    <option value="type">按类别查询</option>
                    <option value="all">全部图书</option>
                </select>
            </div>
            <div class="text"><input type="text" name="data"></div>
            <div class="button"><input type="submit" value="图书检索"></div>
            @if(count($errors)>0)
                <ul class="errors">
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            @endif
        </div>
    </form>
</div>
<div class="result">
    @if($isQuery == 1)
        @if(count($books) == 0)
            <p>没有您所要检索的书籍！</p>
        @else
            <p>找到{{count($books)}}条检索结果</p>
            <table border="1" cellspacing="0">
                <tr>
                    <th>书号</th>
                    <th>书名</th>
                    <th>作者</th>
                    <th>出版社</th>
                    <th>类别</th>
                    <th>收录时间</th>
                    <th>操作</th>
                </tr>
                @foreach($books as $book)
                    <form action="/lendBook/{{$book->id}}" method="POST">
                        <input type="hidden" name="_method" value="PUT"/>
                        <tr>
                            <td>{{$book->bookid}}</td>
                            <td>{{$book->name}}</td>
                            <td>{{$book->author}}</td>
                            <td>{{$book->publisher}}</td>
                            <td>{{$book->type}}</td>
                            <td>{{$book->created_at}}</td>
                            <td><input type="submit" name="借书" value="点击借书"></td>
                        </tr>
                    </form>
                @endforeach
            </table>
        @endif
    @endif
</div>
<div class="footer">
    &copy; 2017&nbsp;&nbsp;&nbsp;&nbsp;玉言为光小组版权所有&nbsp;&nbsp;&nbsp;&nbsp;未经授权&nbsp;&nbsp;&nbsp;&nbsp;不得转载&nbsp;&nbsp;&nbsp;&nbsp;杭电ICP备666666号
</div>
</body>
</html>